public class Manager extends Employee {
    private double monthlySalary, bonus;

    public Manager(String name, String id, double monthlySalary, double bonus) {
        super(name, id);
        this.monthlySalary = monthlySalary;
        this.bonus = bonus;
    }

    @Override
    public double calculateSalary() throws WorkTimeException {
        validateBonus();
        return monthlySalary + bonus;
    }

    private void validateBonus() throws WorkTimeException {
        if (bonus < 0) throw new WorkTimeException("奖金不能为负数");
    }

    @Override
    protected String getPosition() { return "管理人员"; }

    public void setMonthlySalary(double monthlySalary) { this.monthlySalary = monthlySalary; }
    public void setBonus(double bonus) throws WorkTimeException {
        this.bonus = bonus;
        validateBonus(); // 立即验证
    }
    public double getBonus() { return bonus; }
}